//
//  Teacher.m
//  OCDay08homework
//
//  Created by dllo on 16/5/31.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "Teacher.h"
#import "OurClass.h"
#import "Student.h"
@implementation Teacher

-(void)exam{
 //   NSArray *newStudentArray = self.ourClass.studentArray;
//    for (Student *stu in newStudentArray){
//        [stu.score setObject:@((arc4random() % 100 + 1)) forKey:@"math"];
//    }
    //随机key值
    
    
    for (NSInteger i = 0;i < self.ourClass.studentArray.count;i++){
        [[self.ourClass.studentArray[i] score] setObject:@((arc4random() % 100 + 1)) forKey:[self keyForRandom]];
    }

}

-(instancetype)initWithName:(NSString *)name withAge:(NSInteger)age{
    self = [super self];
    if(self){
        self.name = name;
        self.age = age;
    }
    return self;
}
//随机科目
-(NSString *)keyForRandom{
    NSInteger a = arc4random() % 3 + 1;
    if(a == 1){
        return @"math";
    } else if(a == 2){
        return @"chinese";
    } else {
        return @"english";
    }
}
@end
